import Vue from 'vue';
import App from './App.vue';
import router from './router';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios';       
import { handleTree } from "./utils/ruoyi";
import * as echarts from 'echarts';
import './assets/icon/iconfont.css'
import 'echarts-gl';

import VueAMap from 'vue-amap'

Vue.prototype.$echarts = echarts

import errorHandler from './utils/errorHandler';

// 设置axios的拦截器
axios.interceptors.response.use(
  response => response,
  error => {
    errorHandler(error);
    return Promise.reject(error);
  }
);

Vue.prototype.$http = axios
Vue.prototype.handleTree = handleTree


axios.defaults.baseURL="http://localhost:8030/"
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'

axios.interceptors.request.use(function (config){
    let token =localStorage.getItem("token")
    if(token){
      config.headers['Authorization'] = "Bearer"+token
      return config;
    }
   return config;
}, function (error){
  return Promise.reject(error)
})

Vue.use(VueAMap);
VueAMap.initAMapApiLoader({
  // 高德的key
	key: '79dbe40608c111595c53768ecc1a3abe',
	// 插件集合
	plugin: [
		'AMap.CircleEditor',// 圆形编辑器插件
		"AMap.Geolocation", // 定位控件，用来获取和展示用户主机所在的经纬度位置
		"AMap.Geocoder", // 地理编码与逆地理编码服务，用于地址描述与坐标间的相互转换
		"AMap.Autocomplete",
		"AMap.PlaceSearch",
		"AMap.CitySearch",
	],
	// 高德 sdk 版本，默认为 1.4.4
	v: '1.4.4'
});
window._AMapSecurityConfig = {
	securityJsCode:'79dbe40608c111595c53768ecc1a3abe',
}

Vue.use(ElementUI)
new Vue({
  router,
  render: h => h(App),
}).$mount('#app')

